/*
 * chargen.cpp
 *
 *  Created on: Jul 19, 2012
 *      Author: bjames
 */

/*******************************************************************************
 ** Government Sanctioned Espionage RPG Server                                **
 ** http://www.government-sanctioned.us/                                      **
 **===========================================================================**
 ** Name: chargen.cpp                                                            **
 ** Description:                         **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE file within             **
 ** this distribution or at $WIKI/display/GOVT/License-software.              **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $GAME_DIR/LICENSE.                   **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 ** Copyright (c) 2009-2012  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// $HeadURL$
// Modified $Date$ by $Author$
// $Id$

#include "chargen.hpp"
#include <iostream>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>

void
Attribute::Randomize()
{
	boost::random::mt19937	gen;
	while(cp)
	{
		boost::random::uniform_int_distribution<> dist(1,cp);
		int incr = dist(gen);

		cp -= incr;
		std::cout << "Randomize = " << incr << " and cp = " << cp << std::endl;

	}
}

void
Attribute::Print()
{
	std::cout << "Strength       " << strength << "(" << Attribute::Bonus(AttributeType::STR) << ")" << std::endl;
	std::cout << "Dexterity      " << dexterity << "(" << Attribute::Bonus(AttributeType::DEX) << ")" <<std::endl;
	std::cout << "Constitution   " << constitution << "(" << Attribute::Bonus(AttributeType::CON) << ")" <<std::endl;
	std::cout << "Intelligence   " << intelligence << "(" << Attribute::Bonus(AttributeType::INT) << ")" <<std::endl;
	std::cout << "Wisdom         " << wisdom << "(" << Attribute::Bonus(AttributeType::WIS) << ")" <<std::endl;
	std::cout << "Charisma       " << charisma << "(" << Attribute::Bonus(AttributeType::CHA) << ")" <<std::endl;
}

int
Attribute::Bonus(AttributeType t)
{
	int bonus = 0;

	switch(t)
	{
	case AttributeType::STR:
		bonus = (strength/2) - 5;
		break;
	case AttributeType::DEX:
		bonus = (dexterity/2) - 5;
		break;
	case AttributeType::CON:
		bonus = (constitution/2) - 5;
		break;
	case AttributeType::INT:
		bonus = (intelligence/2) - 5;
		break;
	case AttributeType::WIS:
		bonus = (wisdom/2) - 5;
		break;
	case AttributeType::CHA:
		bonus = (charisma/2) - 5;
		break;
	}
	return bonus;
}

Attribute::Attribute()
{
	strength = dexterity = constitution = 8;
	intelligence = wisdom = charisma = 8;
	cp = 30;
}

unsigned int
Attribute::operator () (AttributeType t)
{
	switch(t)
	{
	case AttributeType::STR: return strength; break;
	case AttributeType::DEX: return dexterity; break;
	case AttributeType::CON: return constitution; break;
	case AttributeType::INT: return intelligence; break;
	case AttributeType::WIS: return wisdom; break;
	case AttributeType::CHA: return charisma; break;
	}
	return 0;
}



